package com.platform.service.impl;

import com.platform.annotation.SysLog;
import com.platform.common.ServerResponse;
import com.platform.dao.ExamineMapper;
import com.platform.pojo.Examine;
import com.platform.service.IExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 审核信息记录服务层
 */
@Service
public class ExamineServiceImpl implements IExamineService {


    @Autowired
    private ExamineMapper examineMapper;

    /**
     * 根据条件查询审核信息记录
     * @param catalog
     * @param type
     * @param value
     * @return
     */
    @SysLog("查询审核信息记录")
    public ServerResponse<List<Examine>> selectByParam(String catalog,String type,Integer value){
        List<Examine> examineList = examineMapper.selectByParam(catalog,type,value);
        if(null != examineList && 0 < examineList.size()){
            return ServerResponse.createBySuccess("查询成功",examineList);
        }
        return ServerResponse.createByErrorMessage("查询失败");
    }

    /**
     * 新增审核信息记录
     * @param catalog
     * @param type
     * @param value
     * @param userName
     * @return
     */
    @SysLog("新增审核信息记录")
    public ServerResponse<String> addExamine(String catalog,String type,Integer value,String userName){
        Examine examine = new Examine();
        examine.setCatalog(catalog);
        examine.setType(type);
        examine.setValue(value);
        examine.setOperator(userName);
        if(examineMapper.insert(examine) > 0){
            return ServerResponse.createBySuccessMessage("保存成功");
        }
        return ServerResponse.createByErrorMessage("保存失败");
    }
}
